package com.gjy.spring.s8.scope;

import org.springframework.beans.factory.ObjectFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @author 宫静雨
 * @version 1.0
 * @since 2023-12-20 11:27:53
 */
@Component
public class E {

    @Resource
    @Lazy  // 添加@Lazy后会是不同的对象
    private F f;
    @Resource
    private F2 f2;
    @Autowired
    private ObjectFactory<F3> f3; // 获取的类型是本身类型，不是代理类型
    @Resource
    private ApplicationContext applicationContext; // 获取的类型是本身类型，不是代理类型

    public F getF() {
        return f;
    }

    public F2 getF2() {
        return f2;
    }

    public F3 getF3() {
        return f3.getObject();
    }
    public F4 getF4() {
        return applicationContext.getBean(F4.class);
    }
}
